<template>
	<view class="page">
		<uni-card>
			<image style="width: 100%; height: 450rpx; background-color: #eeeeee;" :mode="mode"
				:src="classificationInfo.imageUrl">
			</image>
		</uni-card>
		<uni-section v-if="classificationInfo.classLabel" type="line" title="名称">
			<uni-card>
				{{classificationInfo.classLabel}}
			</uni-card>
		</uni-section>
		
		<uni-section v-if="classificationInfo.scientificName"  type="line" title="学名">
			<uni-card>
				{{classificationInfo.scientificName}}
			</uni-card>
		</uni-section>
		
		<uni-section v-if="classificationInfo.features" type="line" title="特征">
			<uni-card>
				{{classificationInfo.features}}
			</uni-card>
		</uni-section>
		
		<uni-section v-if="classificationInfo.originPlace" type="line" title="产地">
			<uni-card>
				{{classificationInfo.originPlace}}
			</uni-card>
		</uni-section>
		
		<uni-section v-if="classificationInfo.purpose" type="line" title="功效">
			<uni-card>
				{{classificationInfo.purpose}}
			</uni-card>
		</uni-section>
		

	</view>
</template>
<script>
	import {
		distinguish,
		getCategoryById
	} from '@/network/api/classification.js'
	export default {
		data() {
			return {
				filePath: 'http://192.168.5.129:9000/vegetable/classification/5f77b4b4001e454f9e3a67fec9c92768.png',
				mode: 'aspectFit',
				classificationInfo: {},
				classification: {}
			}
		},
		onLoad(option) {

			console.log("classId的值为：" + option.classId)
			const query = {
				classId: option.classId
			}
			if(option.fileName!=undefined){
				this.distinguish(option.fileName)
			}else{
				this.init(query)
			}
			

			// uni.request({
			//     url: 'http://192.168.234.216:1234/classification/distinguish', //仅为示例，并非真实接口地址。
			//     data: {
			//         fileName: option.fileName
			//     },
			// 	method:'GET',
			// 	success: (res) => {
			// 		//获得筛选的结果
			// 	        console.log(res.data);
			// 			//将返回的信息显示在页面上

			// 	    }
			// });
			// distinguish(option.fileName).then(result=>{
			// 	console.log(result)
			// })

		},
		methods: {
			init(query) {
				getCategoryById(query).then(result => {
					console.log(result)
					this.classificationInfo = result.data
				})
			},
			distinguish(fileName) {
				
				distinguish(fileName).then(result=>{
					this.classificationInfo = result.data
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page{
		margin-bottom: 20px;
	}
</style>
